﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Init {
    import flash.events.*;
    import Engine.Managers.*;
    import Engine.Init.*;
    import flash.utils.*;
    import Classes.*;
    import Classes.util.*;
    import __AS3__.vec.*;
    import validation.*;
    import scripting.*;
    import Display.*;
    import Modules.stats.experiments.*;
    import Classes.announcements.*;
    import flash.system.*;
    import flash.net.*;
    import Engine.*;
    import Modules.stats.trackers.*;
    import Modules.stats.types.*;
    import Modules.freegiftsale.*;

    public class GameSettingsInit extends InitializationAction {

        public static const INIT_ID:String = "GameSettingsInit";
        private static const MOTD_ICON_BACKLOG_MAX:int = 3;

        private static var debugCalls:int = 0;

        private var m_settingsUrl:String;
        private var m_xml:XMLList;
        private var m_rawXml:XML;
        public var m_effectsConfigXml:XML;
        private var m_items:Dictionary;
        private var m_themeItems:Dictionary;
        private var m_itemLoaded:int = 0;
        private var m_newItems:Array;
        private var m_itemsByType:Dictionary = null;
        private var m_itemsByClass:Dictionary = null;
        private var m_headquarterToBusiness:Dictionary = null;
        private var m_attributes:Dictionary;
        private var m_inGameDaySeconds:Number;
        private var m_growMultiplier:Number;
        private var m_witherMultiplier:Number;
        private var m_boostGrowMultiplier:Number;
        private var m_boostGrowInstantHourLimit:Number;
        private var m_dailyCollectCycleTimeSeconds:Number;
        private var m_buildMultiplier:Number;
        private var m_buildingSpeedupCostMultiplier:Number;
        private var m_buildingSpeedupTimeMultiplier:Number;
        private var m_buildingSpeedupMaxCount:Number;
        private var m_sets:Dictionary;
        private var m_lootSingleClick:Boolean;
        private var m_progress:int = 0;

        public function GameSettingsInit(_arg1:String){
            this.m_items = new Dictionary();
            this.m_themeItems = new Dictionary();
            this.m_newItems = new Array();
            this.m_attributes = new Dictionary(true);
            super(INIT_ID);
            _weight = 100;
            this.m_settingsUrl = _arg1;
            addDependency(ExperimentsInit.INIT_ID);
            Global.gameSettings = this;
            addDependency(RuntimeVariableInit.INIT_ID);
            addDependency(LoadingInit.INIT_ID);
            GlobalEngine.zaspManager.trackTimingStart("GAME_SETTINGS_INIT");
        }
        public static function getCurrentTime():Number{
            var _local1:Number = (isNaN(Global.player.debugTime)) ? GlobalEngine.getTimer() : (Global.player.debugTime * 1000);
            return (_local1);
        }
        public static function checkDateGate(_arg1:XML):Boolean{
            var _local3:Number;
            var _local4:Number;
            var _local2:Boolean;
            if (((_arg1.limitedStart) && (!((_arg1.limitedStart.toString() == ""))))){
                _local3 = GameUtil.synchronizedDateToNumber(_arg1.limitedStart.toString());
                if (((_arg1.limitedEnd) && (!((_arg1.limitedEnd.toString() == ""))))){
                    _local4 = GameUtil.synchronizedDateToNumber(_arg1.limitedEnd.toString());
                    if ((((_local3 <= GlobalEngine.getTimer())) && ((_local4 >= GlobalEngine.getTimer())))){
                        _local2 = true;
                    } else {
                        _local2 = false;
                    };
                };
            };
            return (_local2);
        }

        override public function execute():void{
            var _local1:URLLoader = new URLLoader(new URLRequest(this.m_settingsUrl));
            _local1.dataFormat = URLLoaderDataFormat.BINARY;
            _local1.addEventListener(Event.COMPLETE, this.onConfigXmlLoaded);
        }
        override public function get progress():int{
            return (this.m_progress);
        }
        private function onConfigXmlLoaded(_arg1:Event):void{
            var raw:* = null;
            var assetUrl:* = null;
            var event:* = _arg1;
            this.m_progress = 80;
            GlobalEngine.log("Init", (("onConfigXmlLoaded pre alloc = " + Number(((System.totalMemory / 0x0400) / 0x0400)).toFixed(1)) + "mb"));
            try {
                raw = Utilities.uncompress(event.target.data);
            } catch(error:Error) {
                raw = event.target.data;
            };
            GlobalEngine.log("Init", (("onConfigXmlLoaded size =  " + raw.length) + " bytes"));
            var xml:* = XML(raw);
            this.m_rawXml = xml;
            this.m_xml = xml..farming;
            GlobalEngine.log("Init", (("onConfigXmlLoaded post alloc = " + Number(((System.totalMemory / 0x0400) / 0x0400)).toFixed(1)) + "mb"));
            if (this.m_xml.length > 0){
                this.m_xml = this.m_xml[0];
            };
            this.populateVariables();
            AssetUrlManager.retire();
            if (((this.m_rawXml.assetIndex) && ((this.m_rawXml.assetIndex.length() > 0)))){
                assetUrl = GlobalEngine.getFlashVar("asset_url").toString();
                new AssetUrlManager(assetUrl, (assetUrl + this.m_rawXml.assetIndex.@hashedPrefix), this.m_rawXml.assetIndex.toString(), this.m_rawXml.assetPackIndex.toString());
                delete this.m_rawXml.assetIndex;
            } else {
                new AssetUrlManager(null, null, null, null);
            };
            AssetUrlManager.instance.setAssetDomains(int(this.getAttribute("assetDomainCount", 2)));
            this.m_inGameDaySeconds = Number(this.getAttribute("inGameDaySeconds"));
            this.m_growMultiplier = Number(this.getAttribute("growMultiplier"));
            this.m_witherMultiplier = Number(this.getAttribute("witherMultiplier"));
            this.m_boostGrowMultiplier = Number(this.getAttribute("boostGrowMultiplier"));
            this.m_boostGrowInstantHourLimit = Number(this.getAttribute("boostGrowInstantHourLimit"));
            this.m_dailyCollectCycleTimeSeconds = Number(this.getAttribute("dailyCollectCycleTimeSeconds"));
            this.m_buildMultiplier = Number(this.getAttribute("buildMultiplier"));
            this.m_buildingSpeedupCostMultiplier = Number(this.getAttribute("buildingSpeedupCostMultiplier"));
            this.m_buildingSpeedupTimeMultiplier = Number(this.getAttribute("buildingSpeedupTimeMultiplier"));
            this.m_buildingSpeedupMaxCount = Number(this.getAttribute("buildingSpeedupMaxCount"));
            this.m_lootSingleClick = true;
            this.initSets();
            StartupSessionTracker.track(StatsPhylumType.STARTUP_GAMESETTINGS);
            this.m_progress = 100;
            dispatchEvent(new Event(Event.COMPLETE));
            GlobalEngine.zaspManager.trackTimingStop("GAME_SETTINGS_INIT");
        }
        private function initSets():void{
            var _local1:XML;
            var _local2:Set;
            this.m_sets = new Dictionary();
            for each (_local1 in this.m_rawXml.sets.set) {
                _local2 = new Set(_local1);
                this.m_sets[_local2.getName()] = _local2;
            };
        }
        public function getSetByName(_arg1:String):Set{
            return (this.m_sets[_arg1]);
        }
        public function populateVariables():void{
            if (this.m_xml){
            };
        }
        public function getAttribute(_arg1:String, _arg2=null){
            var _local3:*;
            if (((!((this.m_attributes[_arg1] == null))) && (!((this.m_attributes[_arg1] == undefined))))){
                _local3 = this.m_attributes[_arg1];
            } else {
                if (((!((this.m_xml[("@" + _arg1)] == null))) && (!((this.m_xml[("@" + _arg1)] == undefined))))){
                    _local3 = this.m_xml[("@" + _arg1)];
                } else {
                    _local3 = _arg2;
                };
                this.m_attributes[_arg1] = _local3;
            };
            return (_local3);
        }
        public function getInstantReadyCropMultiplier(_arg1:int):Number{
            return (Math.max(Number(this.getAttribute(("instantReadyCropCostConstant" + _arg1))), 0.1));
        }
        public function getInstantReadyResidenceMultiplier(_arg1:int):Number{
            return (Math.max(Number(this.getAttribute(("instantReadyResidenceCostConstant" + _arg1))), 0.1));
        }
        public function getString(_arg1:String, _arg2:String=""):String{
            return (this.getAttribute(_arg1, _arg2).toString());
        }
        public function getInt(_arg1:String, _arg2:int=0):int{
            return (parseInt(this.getAttribute(_arg1, _arg2)));
        }
        public function getNumber(_arg1:String, _arg2:Number=0):Number{
            return (Number(this.getAttribute(_arg1, _arg2)));
        }
        public function get newItems():Array{
            return (this.m_newItems);
        }
        public function get inGameDaySeconds():Number{
            return (this.m_inGameDaySeconds);
        }
        public function get growMultiplier():Number{
            return (this.m_growMultiplier);
        }
        public function get witherMultiplier():Number{
            return (this.m_witherMultiplier);
        }
        public function get boostGrowMultiplier():Number{
            return (this.m_boostGrowMultiplier);
        }
        public function get boostGrowInstantHourLimit():Number{
            return (this.m_boostGrowInstantHourLimit);
        }
        public function get dailyCollectCycleTimeSeconds():Number{
            return (this.m_dailyCollectCycleTimeSeconds);
        }
        public function get buildMultiplier():Number{
            return (this.m_buildMultiplier);
        }
        public function get buildingSpeedupCostMultiplier():Number{
            return (this.m_buildingSpeedupCostMultiplier);
        }
        public function get buildingSpeedupTimeMultiplier():Number{
            return (this.m_buildingSpeedupTimeMultiplier);
        }
        public function get buildingSpeedupMaxCount():Number{
            return (this.m_buildingSpeedupMaxCount);
        }
        public function get lootSingleClick():Boolean{
            return (this.m_lootSingleClick);
        }
        public function setAttribute(_arg1:String, _arg2:String):void{
            this.m_xml[("@" + _arg1)] = _arg2;
        }
        public function getAttributes():Array{
            var _local2:XMLList;
            var _local3:int;
            var _local1:Array = [];
            if (this.m_xml){
                _local2 = this.m_xml.@*;
                _local3 = 0;
                while (_local3 < _local2.length()) {
                    _local1.push({
                        name:_local2[_local3].name(),
                        value:_local2[_local3].toString()
                    });
                    _local3++;
                };
            };
            return (_local1);
        }
        public function getXML():XML{
            return (this.m_rawXml);
        }
        public function getPickupNpcs():XMLList{
            return (this.m_rawXml.pickupNpcs.pickupNpc);
        }
        public function getGameNews():XMLList{
            return (this.m_rawXml.gameNews.item);
        }
        public function getAchievementGroups():XMLList{
            return (this.m_rawXml.achievements);
        }
        public function getAchievementGroupByName(_arg1:String):XML{
            var def:* = null;
            var group:* = _arg1;
            def = this.m_rawXml.achievements.group.(@id == group);
            return (((def.length())>0) ? def[0] : null);
        }
        public function getItems():XMLList{
            return (this.m_rawXml.items.item);
        }
        public function getCollections():XMLList{
            return (this.m_rawXml.collections.collection);
        }
        public function getWildernessRegions():XMLList{
            return (this.m_rawXml.wilderness.region);
        }
        public function getWildernessHeatMap():XMLList{
            return (this.m_rawXml.heatMapPoints.point);
        }
        public function getSets():Dictionary{
            return (this.m_sets);
        }
        public function getRandomModifierTables():XML{
            var _local1:XML = this.m_rawXml.randomModifierTables[0];
            return (_local1);
        }
        public function getRandomModifierTable(_arg1:String, _arg2:String):XML{
            var tablesXml:* = null;
            var result:* = null;
            var tableType:* = _arg1;
            var tableName:* = _arg2;
            tablesXml = this.getRandomModifierTables().children();
            result = tablesXml.(((attribute("type") == tableType)) && ((attribute("name") == tableName)))[0];
            return (result);
        }
        public function getLimitedItemRequests():XMLList{
            return (this.m_rawXml.limitedItemRequests.request);
        }
        public function getInitTrayPreloads():XMLList{
            return (this.m_rawXml.initTrayPreloads.preload);
        }
        public function getItemsByTypeXML(_arg1:String, _arg2:String=""):XMLList{
            var _local5:XML;
            var _local6:int;
            var _local7:Array;
            var _local3:XMLList = new XMLList();
            var _local4:int;
            while (_local4 < this.m_rawXml.items.item.length()) {
                _local5 = this.m_rawXml.items.item[_local4];
                if ((((_local5.@type == _arg1)) || ((_local5.@category == _arg1)))){
                    if ((((((_arg2.toLowerCase() == "all")) || ((_arg2 == "")))) || ((_arg2 == _local5.@subtype)))){
                        _local3[_local3.length()] = _local5;
                    };
                };
                if (_local5.tag.length() > 0){
                    _local6 = 0;
                    while (_local6 < _local5.tag.length()) {
                        _local7 = _local5.tag[_local6].split(":");
                        if (_local7[0] == _arg1){
                            if ((((((_arg2.toLowerCase() == "all")) || ((_arg2 == "")))) || ((_arg2 == _local7[1])))){
                                _local3[_local3.length()] = _local5;
                                break;
                            };
                        };
                        _local6++;
                    };
                };
                _local4++;
            };
            return (_local3);
        }
        public function getItemsByType(_arg1:String, _arg2:String=""):Array{
            var defs:* = null;
            var def:* = null;
            var t:* = null;
            var itemName:* = null;
            var type:* = _arg1;
            var subType:String = _arg2;
            if (this.m_itemsByType == null){
                this.m_itemsByType = new Dictionary();
                defs = this.getItems();
                for each (def in defs) {
                    if (def.attribute("type").length() != 0){
                        t = def.attribute("type").toString();
                        if (this.m_itemsByType[t] == null){
                            this.m_itemsByType[t] = [];
                        };
                        this.m_itemsByType[t].push(def.attribute("name").toString());
                    };
                };
            };
            var items:* = [];
            if (this.m_itemsByType[type] != null){
                for each (itemName in this.m_itemsByType[type]) {
                    items.push(this.getItemByName(itemName));
                };
            };
            if (subType != ""){
                items = items.filter(function (_arg1:Item, ... _args):Boolean{
                    return ((((subType == "")) || ((subType == _arg1.subtype))));
                });
            };
            return (items);
        }
        public function getFranchiseTypeFromHeadquarters(_arg1:String):String{
            var _local2:XMLList;
            var _local3:XML;
            var _local4:String;
            if (this.m_headquarterToBusiness == null){
                this.m_headquarterToBusiness = new Dictionary();
                _local2 = this.getItems();
                for each (_local3 in _local2) {
                    if (_local3.hasOwnProperty("headquarters")){
                        _local4 = _local3.headquarters.toString();
                        this.m_headquarterToBusiness[_local4] = _local3.attribute("name").toString();
                    };
                };
            };
            return (this.m_headquarterToBusiness[_arg1]);
        }
        public function getItemsByClassName(_arg1:String):Array{
            var _local3:XMLList;
            var _local4:XML;
            var _local5:String;
            var _local6:String;
            if (this.m_itemsByClass == null){
                this.m_itemsByClass = new Dictionary();
                _local3 = this.getItems();
                for each (_local4 in _local3) {
                    if (_local4.attribute("className").length() != 0){
                        _local5 = _local4.attribute("className").toString();
                        if (this.m_itemsByClass[_local5] == null){
                            this.m_itemsByClass[_local5] = [];
                        };
                        this.m_itemsByClass[_local5].push(_local4.attribute("name").toString());
                    };
                };
            };
            var _local2:Array = [];
            if (this.m_itemsByClass[_arg1] != null){
                for each (_local6 in this.m_itemsByClass[_arg1]) {
                    _local2.push(this.getItemByName(_local6));
                };
            };
            return (_local2);
        }
        public function getItemsByKeywords(_arg1:Array):Array{
            var dasKeyword:* = null;
            var items:* = null;
            var validItem:* = null;
            var requiredKeywords:* = _arg1;
            var validItems:* = this.getItems();
            for each (dasKeyword in requiredKeywords) {
                validItems = validItems.(child("keyword").contains(dasKeyword));
            };
            items = [];
            for each (validItem in validItems) {
                items.push(this.getItemByName(validItem.attribute("name")));
            };
            return (items);
        }
        public function setupSaleAndNewItems():void{
            var _local2:XML;
            var _local3:int;
            var _local4:Boolean;
            var _local5:Item;
            var _local6:Boolean;
            var _local7:String;
            var _local8:int;
            var _local1:XMLList = this.m_rawXml.newitems.item;
            for each (_local2 in _local1) {
                _local5 = this.getItemByName(_local2.@name);
                _local6 = true;
                if (_local5.experiments){
                    for (_local7 in _local5.experiments) {
                        _local8 = Global.experimentManager.getVariant(_local7);
                        if ((_local5.experiments[_local7] as Array).indexOf(_local8) < 0){
                            _local6 = false;
                            break;
                        };
                    };
                };
                if (((_local6) && (_local5.buyable))){
                    this.m_newItems.push(_local5);
                };
            };
            _local3 = Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_STARTER_PACK);
            _local4 = (((_local3 > 0)) && ((Global.player.hasMadePurchase == false)));
            if (_local4 === true){
                this.m_newItems = this.m_itemsByType[("starter_pack" + _local3)].concat(this.m_newItems);
            };
        }
        public function getPlaceableItems(_arg1:String):Array{
            var type:* = _arg1;
            return (this.getItemsByType(type).filter(function (_arg1:Item, ... _args):Boolean{
                return (_arg1.placeable);
            }));
        }
        public function getBuyableItems(_arg1:String):Array{
            var type:* = _arg1;
            return (this.getItemsByType(type).filter(function (_arg1:Item, ... _args):Boolean{
                return (_arg1.buyable);
            }));
        }
        public function getCurrentBuyableItems(_arg1:String):Array{
            var item:* = null;
            var type:* = _arg1;
            var initArray:* = this.getItemsByType(type).filter(function (_arg1:Item, ... _args):Boolean{
                var _local3:*;
                var _local4:*;
                if (_arg1.noMarket){
                    return (false);
                };
                if (!_arg1.buyable){
                    return (false);
                };
                if (_arg1.experiments){
                    for (_local3 in _arg1.experiments) {
                        _local4 = Global.experimentManager.getVariant(_local3);
                        if ((_arg1.experiments[_local3] as Array).indexOf(_local4) < 0){
                            return (false);
                        };
                    };
                };
                return (true);
            });
            var nonLimitedArray:* = new Array();
            var itemIdx:* = 0;
            while (itemIdx < initArray.length) {
                item = initArray[itemIdx];
                if (this.isCurrentItem(item)){
                    nonLimitedArray.push(item);
                };
                itemIdx = (itemIdx + 1);
            };
            return (nonLimitedArray);
        }
        public function isCurrentItem(_arg1:Item):Boolean{
            var _local2:Boolean;
            var _local3:Number = GlobalEngine.getTimer();
            if (((isNaN(_arg1.startDate)) && (isNaN(_arg1.endDate)))){
                return (true);
            };
            if (((((_arg1.startDate) && (!(isNaN(_arg1.startDate))))) && (!((_arg1.startDate.toString() == ""))))){
                if (_local3 < Number(_arg1.startDate)){
                    _local2 = false;
                };
            };
            if (((!(isNaN(_arg1.endDate))) && ((getCurrentTime() >= Number(_arg1.endDate))))){
                _local2 = false;
            };
            return (_local2);
        }
        public function getSpecialItems():XMLList{
            var _local3:XML;
            var _local1:XMLList = new XMLList();
            var _local2:int;
            while (_local2 < this.m_rawXml.items.item.length()) {
                _local3 = this.m_rawXml.items.item[_local2];
                if (this.isSpecialItem(_local3)){
                    _local1[_local1.length()] = _local3;
                };
                _local2++;
            };
            return (_local1);
        }
        public function isSpecialItem(_arg1:XML):Boolean{
            var _local2:Boolean;
            if (((_arg1.@buyable) && ((_arg1.@buyable.toString() == "true")))){
                if (((_arg1.lootTable) && (!((_arg1.lootTable.toString() == ""))))){
                    _local2 = true;
                } else {
                    if (((_arg1.limitedStart) && (!((_arg1.limitedStart.toString() == ""))))){
                        _local2 = true;
                    } else {
                        if (((_arg1.@marketSpecial) && (!((_arg1.@marketSpecial.toString() == ""))))){
                            _local2 = true;
                        };
                    };
                };
            };
            return (_local2);
        }
        public function getMenuItems():XMLList{
            var _local1:XMLList = this.m_rawXml.marketmenu.menuitem;
            return (_local1);
        }
        public function getBuyableCategories(_arg1:String):Array{
            var _local4:XML;
            var _local5:String;
            var _local2:XMLList = this.m_rawXml.marketmenu.menuitem;
            var _local3:Array = new Array();
            for each (_local4 in _local2) {
                if (_local4.@type == _arg1){
                    _local5 = _local4.@alsoBuys;
                };
            };
            if (((_local5) && (!((_local5 == ""))))){
                _local3 = _local5.split(",");
            };
            return (_local3);
        }
        public function getLimitedIcons():XMLList{
            var _local1:XMLList = this.m_rawXml.marketmenu.limitedIcons;
            return (_local1);
        }
        public function getPlayerClasses():XMLList{
            return (this.m_rawXml.playerClasses.playerClass);
        }
        public function getSubMenuItemsByMenuType(_arg1:String):XMLList{
            var results:* = null;
            var menuType:* = _arg1;
            results = this.m_rawXml.marketmenu.menuitem.(@type == menuType).submenuitem;
            return (results);
        }
        public function getMissionByType(_arg1:String):XMLList{
            var missionType:* = _arg1;
            return (this.m_rawXml.missions.mission.(@type == missionType));
        }
        public function getThemeByNames(_arg1:Vector.<String>):IThemeDefinition{
            var _local2:Vector.<XML>;
            var _local3:String;
            if (this.m_themeItems[this.getThemesKey(_arg1)] == null){
                _local2 = new Vector.<XML>();
                for each (_local3 in _arg1) {
                    _local2.push(this.getThemeXMLByName(_local3));
                };
                this.m_themeItems[this.getThemesKey(_arg1)] = new ThemeListDefinition(_local2);
            };
            return (this.m_themeItems[this.getThemesKey(_arg1)]);
        }
        public function getItemByNameAndThemes(_arg1:String, _arg2:Vector.<Theme>):Item{
            var _local4:Theme;
            var _local5:IThemeDefinition;
            var _local6:Item;
            var _local3:Vector.<String> = new Vector.<String>();
            for each (_local4 in _arg2) {
                _local3.push(_local4.name);
            };
            _local5 = this.getThemeByNames(_local3);
            _local6 = _local5.getThemeItemByName(_arg1);
            return (_local6);
        }
        private function getThemesKey(_arg1:Vector.<String>):String{
            return (_arg1.toString());
        }
        private function getThemeXMLByName(_arg1:String):XML{
            var _local3:XML;
            var _local2:XML;
            for each (_local3 in this.m_rawXml.themes.theme) {
                if (_local3.@name == _arg1){
                    _local2 = _local3;
                    break;
                };
            };
            return (_local2);
        }
        public function parseAllItems():void{
            var _local1:XML;
            var _local2:String;
            var _local3:Item;
            for each (_local1 in this.m_rawXml.items.item) {
                _local2 = String(_local1.@name);
                if (this.m_items[_local2] == null){
                    _local3 = new Item(_local1);
                    this.m_items[_local2] = _local3;
                };
            };
        }
        public function getItemByName(_arg1:String):Item{
            var _local3:XML;
            var _local2:Item = this.m_items[_arg1];
            if (_local2 == null){
                _local3 = this.getItemXMLByName(_arg1);
                _local2 = this.createItemByXML(_local3);
            };
            return (_local2);
        }
        private function createItemByXML(_arg1:XML):Item{
            var _local3:Item;
            if (_arg1 == null){
                return (null);
            };
            var _local2:Item = new Item(_arg1);
            this.m_items[_local2.name] = _local2;
            this.m_itemLoaded++;
            if (_local2.className == "Headquarter"){
                _local3 = this.getItemByName(this.getFranchiseTypeFromHeadquarters(_local2.name));
                if (_local3){
                    _local2.localizedName = ZLoc.t("Items", "headquarters", {item:_local3.localizedName});
                };
            };
            return (_local2);
        }
        public function getEffectByName(_arg1:String):XML{
            var list:* = null;
            var result:* = null;
            var effectName:* = _arg1;
            list = this.m_rawXml.effects.effect.(@name == effectName);
            result = null;
            if (list.length()){
                result = list[0];
            };
            return (result);
        }
        public function getScaffoldSetByName(_arg1:String):XMLList{
            var list:* = null;
            var result:* = null;
            var scaffoldName:* = _arg1;
            list = this.m_rawXml.scaffolds.scaffold.(@name == scaffoldName);
            result = null;
            if (list.length()){
                result = list.image;
            };
            return (result);
        }
        public function getRibbonSetByName(_arg1:String):XMLList{
            var list:* = null;
            var result:* = null;
            var ribbonName:* = _arg1;
            list = this.m_rawXml.ribbons.ribbon.(@name == ribbonName);
            result = null;
            if (list.length()){
                result = list.image;
            };
            return (result);
        }
        public function parseValidateTag(_arg1:XML):GenericValidationScript{
            var _local3:GenericValidationScript;
            var _local4:GenericValidationConditionSet;
            var _local5:XML;
            var _local2:String = _arg1.@name;
            if (_local2){
                _local3 = new GenericValidationScript(_local2);
                _local4 = new GenericValidationConditionSet(GenericValidationConditionSet.EVALUATE_OR);
                for each (_local5 in _arg1.children()) {
                    this.parseValidateTagCondition(_local5, _local4);
                };
                _local3.conditionSet = _local4;
                return (_local3);
            };
            return (null);
        }
        protected function parseValidateTagCondition(_arg1:XML, _arg2:GenericValidationConditionSet):void{
            var _local4:GenericValidationConditionSet;
            var _local5:XML;
            var _local6:String;
            var _local7:String;
            var _local8:Object;
            var _local9:XML;
            var _local10:GenericValidationCondition;
            var _local11:String;
            var _local12:String;
            var _local3:String = _arg1.name();
            if (_local3 == "func"){
                _local8 = {};
                for each (_local9 in _arg1.attributes()) {
                    _local11 = _local9.name();
                    _local12 = _arg1.attribute(_local11);
                    switch (_local11){
                        case "_class":
                            _local6 = _local12;
                            break;
                        case "_name":
                            _local7 = _local12;
                            break;
                        default:
                            _local8[_local11] = _local12;
                    };
                };
                _local10 = new GenericValidationCondition(_local6, _local7, _local8);
                _arg2.add(_local10);
                return;
            };
            switch (_local3){
                case "anyOf":
                    _local4 = new GenericValidationConditionSet(GenericValidationConditionSet.EVALUATE_OR);
                    break;
                case "allOf":
                    _local4 = new GenericValidationConditionSet(GenericValidationConditionSet.EVALUATE_AND);
                    break;
            };
            for each (_local5 in _arg1.children()) {
                this.parseValidateTagCondition(_local5, _local4);
            };
            if (_local4){
                _arg2.add(_local4);
            };
        }
        public function parseScriptTag(_arg1:XML, _arg2:IScriptingContext):Script{
            var _local4:XML;
            var _local5:Function;
            var _local6:Object;
            var _local7:XML;
            var _local8:String;
            var _local9:String;
            var _local3:Script = new Script(_arg2);
            if (_arg1){
                for each (_local4 in _arg1.condition) {
                    _local5 = Global.scriptingManager.getConditionFunction(_local4.@eval);
                    if (_local5 != null){
                        _local6 = {};
                        for each (_local7 in _local4.attributes()) {
                            _local8 = _local7.name();
                            _local9 = _local4.attribute(_local8);
                            if (_local8 != "eval"){
                                _local6[_local8] = _local9;
                            };
                        };
                        _local3.addCondition(_local4.@eval, _local6);
                    };
                };
            };
            return (_local3);
        }
        public function getAnnouncers():XMLList{
            return (this.m_rawXml.child("announcers").child("announcer"));
        }
        public function getAnnouncements():Array{
            var _local2:XML;
            var _local3:XML;
            var _local4:Object;
            var _local5:XML;
            var _local6:AnnouncementData;
            var _local7:XML;
            var _local8:String;
            var _local9:String;
            var _local10:Object;
            var _local11:XML;
            var _local12:Script;
            var _local1:Array = new Array();
            for each (_local2 in this.m_rawXml.announcements.announcement) {
                _local3 = _local2.dialog[0];
                _local4 = {};
                for each (_local5 in _local3.attributes()) {
                    _local8 = _local5.name();
                    _local9 = _local5;
                    _local4[_local8] = _local9;
                };
                if (_local3.closeCallback.length() > 0){
                    _local10 = new Object();
                    _local10.name = String(_local3.closeCallback.@name);
                    _local10.params = new Array();
                    for each (_local11 in _local3.closeCallback.param) {
                        _local10.params.push(String(_local11));
                    };
                    _local4["closeCallback"] = _local10;
                };
                _local6 = new AnnouncementData(_local2.@id, _local4, _local2.@priority);
                for each (_local7 in _local2.script) {
                    _local12 = this.parseScriptTag(_local7, _local6);
                    _local6.attachScript(_local12);
                };
                _local1.push(_local6);
            };
            return (_local1);
        }
        public function getFlashSaleData():Array{
            var _local3:XML;
            var _local4:Object;
            var _local5:Array;
            var _local6:XML;
            var _local7:Object;
            var _local8:XML;
            var _local9:String;
            var _local10:String;
            var _local1:Array = new Array();
            var _local2:XMLList = Global.experimentManager.filterXmlByExperiment(this.m_rawXml.flashSale);
            for each (_local3 in _local2) {
                _local4 = {};
                _local4.packageSetId = parseInt(_local3.pkgSetId[0].toString());
                _local5 = new Array();
                for each (_local6 in _local3.featuredSaleData.pkg) {
                    _local7 = {};
                    for each (_local8 in _local6.attributes()) {
                        _local9 = _local8.name();
                        _local10 = _local8;
                        _local7[_local9] = _local10;
                    };
                    _local5.push(_local7);
                };
                _local4.featuredSales = _local5;
                _local1.push(_local4);
            };
            return (_local1);
        }
        public function getFreeGiftSaleData():Array{
            var _local3:XML;
            var _local4:Object;
            var _local5:Array;
            var _local6:Number;
            var _local7:XML;
            var _local8:Object;
            var _local9:XML;
            var _local10:String;
            var _local11:String;
            var _local1:Array = new Array();
            var _local2:XMLList = Global.experimentManager.filterXmlByExperiment(this.m_rawXml.freeGiftSale);
            for each (_local3 in _local2) {
                _local4 = {};
                _local4.packageSetId = parseInt(_local3.pkgSetId[0].toString());
                _local5 = new Array();
                _local6 = DateFormatter.parseTimeString(RuntimeVariableManager.getString("FREE_GIFT_OFFER_END_DATE", "01/01/2011"));
                FreeGiftSaleManager.endDate = _local6;
                for each (_local7 in _local3.featuredSaleData.pkg) {
                    _local8 = {endDate:_local6};
                    for each (_local9 in _local7.attributes()) {
                        _local10 = _local9.name();
                        _local11 = _local9;
                        _local8[_local10] = _local11;
                    };
                    _local5.push(_local8);
                };
                _local4.featuredSales = _local5;
                _local1.push(_local4);
            };
            return (_local1);
        }
        public function getXpromos():Array{
            var _local2:XML;
            var _local3:Object;
            var _local4:XML;
            var _local5:String;
            var _local6:String;
            var _local1:Array = [];
            for each (_local2 in this.m_rawXml.inGameXpromos.xpromo) {
                _local3 = {};
                for each (_local4 in _local2.attributes()) {
                    _local5 = String(_local4.name());
                    _local6 = String(_local4);
                    _local3[_local5] = _local6;
                };
                _local1.push(_local3);
            };
            return (_local1);
        }
        public function getCollectionXMLByName(_arg1:String):XML{
            var result:* = null;
            var list:* = null;
            var name:* = _arg1;
            result = null;
            list = this.m_rawXml.collections.collection.(@name == name);
            if (list.length()){
                result = list[0];
            };
            return (result);
        }
        public function getItemXMLByCode(_arg1:String):XML{
            var list:* = null;
            var result:* = null;
            var code:* = _arg1;
            list = this.m_rawXml.items.item.(@code == code);
            result = null;
            if (list.length()){
                result = list[0];
            };
            return (result);
        }
        public function getItemByCode(_arg1:String):Item{
            var _local2:Item;
            var _local3:XML;
            if (_arg1 != null){
                _local3 = this.getItemXMLByCode(_arg1);
                _local2 = this.createItemByXML(_local3);
            };
            return (_local2);
        }
        public function getItemProgenitorName(_arg1:String):String{
            var ancestorNames:* = null;
            var ancestorName:* = null;
            var itemName:* = _arg1;
            ancestorNames = this.m_rawXml.items.item.(child("upgrade").attribute("item") == itemName).attribute("name");
            if (ancestorNames.length() > 0){
                ancestorName = ancestorNames[0].toString();
                return (this.getItemProgenitorName(ancestorName));
            };
            return (itemName);
        }
        public function getItemNamesInUpgradeHeirarchy(_arg1:String):Array{
            var nextDescendantNames:* = null;
            var itemName:* = _arg1;
            var descendantName:* = this.getItemProgenitorName(itemName);
            var upgradeHeirarchy:* = [];
            do  {
                upgradeHeirarchy.push(descendantName);
                nextDescendantNames = this.m_rawXml.items.item.(attribute("name") == descendantName).child("upgrade").attribute("item");
                descendantName = ((nextDescendantNames.length() > 0)) ? nextDescendantNames[0].toString() : null;
            } while (descendantName);
            return (upgradeHeirarchy);
        }
        public function getXpromoXML():XMLList{
            return (this.m_rawXml.xpromos.xpromo);
        }
        public function getXpromoXMLByName(_arg1:String):XML{
            var list:* = null;
            var source:* = _arg1;
            list = this.m_rawXml.xpromos.xpromo.(@src == source);
            return (((list.length() == 1)) ? list[0] : null);
        }
        public function getCommodityXML():XMLList{
            return (this.m_rawXml.commodities.commodity);
        }
        public function getCommodityMax(_arg1:String):int{
            var _local2:XML = this.getCommodityXMLByName(_arg1);
            return (((_local2)!=null) ? int(_local2.@max) : 0);
        }
        public function getCommodityMinLevel(_arg1:String):int{
            var _local2:XML = this.getCommodityXMLByName(_arg1);
            return (((_local2)!=null) ? int(_local2.@minLevel) : 0);
        }
        public function getCommodityBonus(_arg1:String):int{
            var _local2:XML = this.getCommodityXMLByName(_arg1);
            return (((_local2)!=null) ? int(_local2.@bonus) : 0);
        }
        public function getCommodityXMLByName(_arg1:String):XML{
            var list:* = null;
            var nameStr:* = _arg1;
            list = this.m_rawXml.commodities.commodity.(@name == nameStr);
            return (((list.length())>0) ? list[0] : null);
        }
        public function getCommodityXMLDefault():XML{
            var list:* = null;
            list = this.m_rawXml.commodities.commodity.(@default == "1");
            return (((list.length())>0) ? list[0] : null);
        }
        public function getExpansionXMLByNum(_arg1:Number):XML{
            var num:* = _arg1;
            var retVal:* = this.m_rawXml.expansions.expansion[num];
            return (((retVal)!=null) ? retVal : this.m_rawXml.expansions.expansion.(@num == "MAX")[0]);
        }
        public function getExpansionXML():XMLList{
            return (this.m_rawXml.expansions.expansion);
        }
        public function getViralXML():XMLList{
            return (this.m_rawXml.virals.viral);
        }
        public function getViralXMLByName(_arg1:String):XML{
            var list:* = null;
            var nameStr:* = _arg1;
            list = this.m_rawXml.virals.viral.(@name == nameStr);
            return (((list.length())>0) ? list[0] : null);
        }
        public function getMasteryXMLByCode(_arg1:String):XML{
            var list:* = null;
            var result:* = null;
            var code:* = _arg1;
            list = this.m_rawXml.items.item.(@code == code);
            result = null;
            if (list.length()){
                result = list[0];
            };
            return (result);
        }
        public function getReputationLevelXML(_arg1:int):XML{
            var list:* = null;
            var result:* = null;
            var level:* = _arg1;
            list = this.m_rawXml.reputation.level.(@num == level);
            result = null;
            if (list.length()){
                result = list[0];
            };
            return (result);
        }
        public function getLevelXML(_arg1:int):XML{
            var list:* = null;
            var result:* = null;
            var level:* = _arg1;
            list = this.getLevelsXML().level.(@num == level);
            result = null;
            if (list.length()){
                result = list[0];
            };
            return (result);
        }
        public function getLevelsXML():XMLList{
            var _local1:int = Global.gameSettings.getInt("levelsCvLevelTop");
            var _local2:int = Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_LEVEL_REGRADE);
            if (_local2){
                return (this.m_rawXml.child(("levels_cv_level_regrade_var_" + _local1.toString())));
            };
            return (this.m_rawXml.levels_cv_level_regrade_var_0);
        }
        public function getItemXMLByName(_arg1:String):XML{
            var results:* = null;
            var nameStr:* = _arg1;
            results = this.m_rawXml.items.item.(@name == nameStr);
            return (((results.length())>0) ? (results[0] as XML) : null);
        }
        public function getItemFriendlyName(_arg1:String):String{
            var _local2:String = ZLoc.t("Main", "BadItemName");
            var _local3:Item = this.getItemByName(_arg1);
            if (_local3){
                _local2 = _local3.localizedName;
            };
            return (_local2);
        }
        public function getItemCellView(_arg1:String):String{
            var _local2:XML = Global.gameSettings.getItemXMLByName(_arg1);
            if (((_local2) && (_local2.attribute("viewClass")))){
                return (_local2.@viewClass);
            };
            return (null);
        }
        public function getImageByName(_arg1:String, _arg2:String):String{
            var images:* = null;
            var outerXML:* = null;
            var itemName:* = _arg1;
            var imageName:* = _arg2;
            var iteminst:* = this.getItemByName(itemName);
            var item:* = ((iteminst)!=null) ? iteminst.xml : null;
            var result:* = null;
            if (item){
                images = item.image.(@name == imageName);
                if (images.length()){
                    outerXML = (images[0] as XML);
                    if (images[0].children().length() > 0){
                        result = Global.getAssetURL(outerXML.children()[0].@url);
                    } else {
                        result = Global.getAssetURL(outerXML.@url);
                    };
                };
            };
            return (result);
        }
        public function getDisplayedStatsByName(_arg1:String):Dictionary{
            var _local2:XML = this.getItemXMLByName(_arg1);
            var _local3:XMLList = _local2.displayedStats;
            return (this.parseDisplayedStats(_arg1, _local3));
        }
        public function parseDisplayedStats(_arg1:String, _arg2:XMLList, _arg3:String=null):Dictionary{
            var _local6:XML;
            var _local7:String;
            var _local4:Item = Global.gameSettings.getItemByName(_arg1);
            var _local5:Dictionary = new Dictionary();
            if (((_local4) && (_arg2))){
                for each (_local6 in _arg2.children()) {
                    _local7 = String(_local6.@type);
                    switch (_local7){
                        case "coin":
                        case "xp":
                        case "goods":
                        case "premium_goods":
                        case "energy":
                            if (_local6.@value.length() > 0){
                                _local5[_local7] = int(_local6.@value);
                            } else {
                                _local5[_local7] = Global.player.GetDooberMinimums(_local4, _local7, _arg3);
                            };
                            break;
                        case "population":
                            if (_local6.@value.length() > 0){
                                _local5[_local7] = int(_local6.@value);
                            } else {
                                _local5[_local7] = (_local4.populationCapYield * Global.gameSettings.getNumber("populationScale", 10));
                            };
                            break;
                        case "bonus":
                            if (_local5[_local7] == null){
                                _local5[_local7] = new Array();
                            };
                            (_local5[_local7] as Array).push(String(_local6.@value));
                            break;
                        case "picture":
                            _local5[_local7] = String(_local6.@value);
                            break;
                        case "item":
                        case "collectable":
                            if (_local5[_local7] == null){
                                _local5[_local7] = new Object();
                            };
                            _local5[_local7].name = String(_local6.@value);
                            _local5[_local7].count = int(_local6.@count);
                            break;
                    };
                };
            };
            return (_local5);
        }
        public function getIconByCode(_arg1:String):QueuedIcon{
            var _local2:QueuedIcon;
            var _local3:XML = this.getIconXMLByCode(_arg1);
            if (_local3){
                _local2 = new QueuedIcon(_local3);
            };
            return (_local2);
        }
        public function getIconByName(_arg1:String):QueuedIcon{
            var _local2:XML = this.getIconXMLByName(_arg1);
            var _local3:QueuedIcon = (_local2) ? new QueuedIcon(_local2) : null;
            return (_local3);
        }
        public function getIconXMLByCode(_arg1:String):XML{
            var list:* = null;
            var result:* = null;
            var code:* = _arg1;
            list = this.m_rawXml.icons.icon.(@code == code);
            result = null;
            if (list.length()){
                result = list[0];
            };
            return (result);
        }
        public function getIconXMLByName(_arg1:String):XML{
            var list:* = null;
            var result:* = null;
            var iconName:* = _arg1;
            list = this.m_rawXml.icons.icon.(@name == iconName);
            result = null;
            if (list.length()){
                result = list[0];
            };
            return (result);
        }
        public function getCurrentMOTD():Object{
            var _local4:XML;
            var _local1:Object;
            var _local2:XMLList = new XMLList();
            var _local3:int;
            while (_local3 < this.m_rawXml.motd.motdItem.length()) {
                _local4 = this.m_rawXml.motd.motdItem[_local3];
                if (checkDateGate(_local4)){
                    _local4["version"] = _local4["@version"];
                    _local1 = _local4;
                    break;
                };
                _local3++;
            };
            return (_local1);
        }
        public function checkDate(_arg1:String, _arg2:String):Boolean{
            var _local3:Date = new Date(_arg1);
            var _local4:Date = new Date(_arg2);
            var _local5:Date = new Date();
            var _local6:Boolean;
            if ((((_local3 < _local5)) && ((_local5 < _local4)))){
                _local6 = true;
            };
            return (_local6);
        }
        private function getCollectionXMLByCollectableName(_arg1:String):XML{
            var _local3:Object;
            var _local4:XMLList;
            var _local5:XML;
            var _local2:XMLList = this.getCollections();
            for (_local3 in _local2) {
                _local4 = _local2[_local3].collectables.children();
                for each (_local5 in _local4) {
                    if (_local5.@name == _arg1){
                        return (_local2[_local3]);
                    };
                };
            };
            return (null);
        }
        public function getCollectionByCollectableName(_arg1:String):Collection{
            var _local2:XML = this.getCollectionXMLByCollectableName(_arg1);
            if (!_local2){
                return (null);
            };
            var _local3:Collection = new Collection(_local2);
            return (_local3);
        }
        public function getDooberFromType(_arg1:String, _arg2:int, _arg3:String=null):String{
            var denom:* = null;
            var denomAmount:* = 0;
            var dooberType:* = _arg1;
            var amount:* = _arg2;
            var specialTable = _arg3;
            var result:* = null;
            var list:* = null;
            if (specialTable != null){
                list = this.getXMLWithAttribute(this.m_rawXml.dooberDisplayTables.dooberDisplayTable, "special", specialTable).children();
            };
            if ((((list == null)) || ((list.length() <= 0)))){
                list = this.m_rawXml.dooberDisplayTables.dooberDisplayTable.(@type == dooberType).children();
            };
            if ((((list == null)) || ((list.length() <= 0)))){
                return (dooberType);
            };
            for each (denom in list) {
                denomAmount = parseInt(denom.@amount);
                if (amount >= denomAmount){
                    return (denom.@name);
                };
            };
            return (dooberType);
        }
        protected function getXMLWithAttribute(_arg1:XMLList, _arg2:String, _arg3:String):XML{
            var _local4:XML;
            for each (_local4 in _arg1) {
                if ((((_local4.attribute(_arg2).length() > 0)) && ((_local4.attribute(_arg2)[0].toString() == _arg3)))){
                    return (_local4);
                };
            };
            return (null);
        }
        public function getTieredInt(_arg1:String, _arg2:int):int{
            var _local3:String = this.getTieredString(_arg1, _arg2);
            return ((_local3) ? int(_local3) : 0);
        }
        public function getTieredString(_arg1:String, _arg2:int):String{
            var list:* = null;
            var tierResult:* = null;
            var tier:* = null;
            var tableName:* = _arg1;
            var num:* = _arg2;
            list = this.m_rawXml.tieredValues.tieredValue.(@name == tableName);
            tierResult = list.children()[0];
            for each (tier in list.children()) {
                if (num < tier.@num){
                    break;
                };
                tierResult = tier;
            };
            return (tierResult.@amount);
        }
        public function getTierXml(_arg1:String):XMLList{
            var tableName:* = _arg1;
            return (this.m_rawXml.tieredValues.tieredValue.(@name == tableName));
        }
        public function getGoldContainerValueByName(_arg1:String):int{
            var result:* = 0;
            var list:* = null;
            var a_name:* = _arg1;
            result = 0;
            list = this.m_rawXml.goldcontainers.goldcontainer.(@name == a_name);
            if (list.length()){
                result = list.@coins;
            };
            return (result);
        }
        public function getGoldContainerURLByName(_arg1:String):String{
            var result:* = null;
            var list:* = null;
            var a_name:* = _arg1;
            result = "";
            list = this.m_rawXml.goldcontainers.goldcontainer.(@name == a_name);
            if (list.length()){
                result = list.@url;
            };
            return (Global.getAssetURL(result));
        }
        public function getCollectionByName(_arg1:String):Collection{
            var _local2:Collection = new Collection(this.getCollectionXMLByName(_arg1));
            return (_local2);
        }
        public function getDailyBonus(_arg1:int):XML{
            var xml:* = null;
            var consecutiveDay:* = _arg1;
            xml = this.m_rawXml.dailyBonus.consecutiveDay.(@number == String(consecutiveDay))[0];
            return (xml);
        }
        public function getDailyBonusMaxRecoveryDays():int{
            var _local1:XML = this.m_rawXml.dailyBonus[0];
            var _local2:int = int(Number(_local1.@maxRecoveryDays));
            return (_local2);
        }
        public function getDailyBonusMaxStreak():int{
            var _local1:XMLList = this.m_rawXml.dailyBonus.consecutiveDay;
            var _local2:int = _local1.length();
            return (_local2);
        }
        public function getValentinesAssets():Dictionary{
            var _local3:XML;
            var _local1:Dictionary = new Dictionary(true);
            var _local2:XMLList = this.m_rawXml.valentines;
            for each (_local3 in _local2.children()) {
                _local1[_local3.name()] = _local3.image;
            };
            return (_local1);
        }
        public function getBanditDataById(_arg1:int):XML{
            var list:* = null;
            var id:* = _arg1;
            list = this.m_rawXml.copsandbandits.bandit.(@id == String(id));
            return (((list.length())>0) ? list[0] : null);
        }
        public function getBanditXML():XMLList{
            return (this.m_rawXml.copsandbandits.bandit);
        }
        public function getPoliceStationNPCs(_arg1:int):XMLList{
            var list:* = null;
            var stationLevel:* = _arg1;
            list = this.m_rawXml.copsandbandits.station.(@level == stationLevel).functionalNPCs.npc;
            return (list);
        }
        public function getPoliceStationNewVehicle(_arg1:int):String{
            var stationLevel:* = _arg1;
            return (this.m_rawXml.copsandbandits.station.(@level == stationLevel).@newVehicle.toString());
        }
        public function getPoliceStationLevel(_arg1:String):int{
            var list:* = null;
            var stationName:* = _arg1;
            list = this.m_rawXml.copsandbandits.station.(@name == stationName);
            return (((list.length())>0) ? int(list[0].attribute("level")) : 0);
        }
        public function getPoliceStationSlots(_arg1:int):int{
            var list:* = null;
            var stationLevel:* = _arg1;
            list = this.m_rawXml.copsandbandits.station.(@level == stationLevel);
            return (((list.length())>0) ? int(list[0].attribute("maxCops")) : 0);
        }
        public function getPoliceStationNameForLevel(_arg1:int):String{
            var list:* = null;
            var stationLevel:* = _arg1;
            list = this.m_rawXml.copsandbandits.station.(@level == stationLevel);
            return (((list.length())>0) ? list[0].attribute("name") : "");
        }
        public function getPoliceStationByLevel(_arg1:int):XML{
            var list:* = null;
            var level:* = _arg1;
            list = this.m_rawXml.copsandbandits.station.(@level == level);
            return (((list.length())>0) ? list[0] : null);
        }
        public function getPopulationTriggersXML():XMLList{
            return (this.m_rawXml.populationTriggers.trigger);
        }
        public function testAllItemAssets():void{
            var _local3:String;
            var _local4:Array;
            var _local5:Array;
            var _local6:Item;
            var _local7:Array;
            var _local8:String;
            var _local9:*;
            var _local10:ItemImageInstance;
            if (!Config.DEBUG_MODE){
                return;
            };
            this.getItemsByType("test");
            ErrorManager.addError("Now loading all assets.");
            var _local1:int;
            var _local2:Array = [Constants.DIRECTION_SW, Constants.DIRECTION_SE, Constants.DIRECTION_NE, Constants.DIRECTION_NW];
            for (_local3 in this.m_itemsByType) {
                _local4 = [];
                switch (_local3){
                    case "residence":
                        _local4 = ["planted", "grown"];
                        break;
                    case "decoration":
                    case "municipal":
                    case "landmark":
                    case "ZooEnclosure":
                    case "business":
                        _local4 = ["static"];
                        break;
                    case "plot":
                    case "ship":
                        _local4 = ["plowed", "planted", "grown", "withered"];
                        break;
                };
                _local5 = this.getItemsByType(_local3);
                for each (_local6 in _local5) {
                    _local7 = _local4;
                    switch (_local6.className){
                        case "Headquarter":
                            _local7 = ["base", "floor", "rooftop", "penthouse", "billboard"];
                            break;
                    };
                    for each (_local8 in _local7) {
                        for each (_local9 in _local2) {
                            _local10 = _local6.getCachedImage(_local8, _local9);
                            if ((((_local10 == null)) && (!(_local6.isCachedImageLoading(_local8, _local9))))){
                                ErrorManager.addError(((((((("ERROR missing asset for item " + _local6.name) + " (") + _local6.localizedName) + "), state ") + _local8) + ", dir ") + _local9));
                                _local1++;
                            };
                        };
                    };
                };
            };
            ErrorManager.addError((("Asset test finished: " + _local1) + " errors found"));
        }
        public function addOrReplaceItemXMLByName(_arg1:XML):void{
            var name:* = null;
            var list:* = null;
            var item:* = _arg1;
            name = String(item.@name);
            list = this.m_rawXml.items.item.(@name == item.@name);
            if (list.length()){
                list[0] = item;
            } else {
                this.m_rawXml.items.appendChild(item);
            };
        }

    }
}//package Init 
